// src/api/business/fence.ts
import { Alova } from '@/utils/http/alova/index';

// 电子围栏数据结构
interface FenceInfo {
  fenceId: string;
  stationId: string;
  coordinatesList: Array<{
    longitude: number;
    latitude: number;
  }>;
  createTime?: string;
  updateTime?: string;
}

const baseApi = '/web/proj/fence';

/**
 * 根据站点ID获取电子围栏
 */
export function getFenceByStationId(params: { stationId: string }) {
  return Alova.Post<InResult<FenceInfo>>(baseApi + '/byStationId', { params });
}

export function getFenceConfig(params:any){
  return Alova.Post<InResult<FenceInfo>>(baseApi + '/config', { params });
}

/**
 * 添加电子围栏
 */
export function addFence(params: Partial<FenceInfo>) {
  return Alova.Post<InResult<FenceInfo>>(baseApi + '/add', { params });
}

/**
 * 更新电子围栏
 */
export function updateFence(params: FenceInfo) {
  return Alova.Post<InResult<FenceInfo>>(baseApi + '/update', { params });
}

export function clearFenceConfig(params:any){
    return Alova.Post<InResult<boolean>>(baseApi + '/clearConfig', { params });
}

export function saveFenceConfig(params:any){
    return Alova.Post<InResult<boolean>>(baseApi + '/saveConfig', { params });
}
/**
 * 删除电子围栏
 */
export function removeFence(params: { id: string }) {
  return Alova.Post<InResult<boolean>>(baseApi + '/remove', { params });
}